/**
 * 
 */
package net.homelinux.ajay.net.ondisk.view.dialogs.client;

import com.google.gwt.user.client.Window;

import net.homelinux.ajay.net.ondisk.view.client.CollectionsTreeItem;

/**
 * @author ajay
 *
 */
public class AddCollectionDialog extends AddNodeDlg {
  public static AddCollectionDialog makeDialog(){
    return new AddCollectionDialog();
  }
  private CollectionsTreeItem parent;

  /**
   * 
   */
  public AddCollectionDialog() {
  }

  /* (non-Javadoc)
   * @see net.homelinux.ajay.net.ondisk.view.dialogs.client.AddNode#getNodeTypeString()
   */
  protected String getNodeTypeString() {
    return "Collection";
  }
  
  public void onOk(){
    String name = getValue();
    if(!parent.addCollection(name)){
      Window.alert("A collection already exists with the name: "+name );
    }
    super.onOk();
  }
  
  
  public void show(CollectionsTreeItem parent) {
    this.parent = parent;
    show();
  }

}
